package edu.sandau.basic.utils;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.Date;

public class Converter {
    public static LocalDateTime dateToLocalDateTime(Date d){
        return d.toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime();
    }
    public static LocalDate dateToLocalDate(Date d){
        return d.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
    }
    public static Date localDateTimeToDate(LocalDateTime l){
        return Date.from(l.atZone(ZoneId.systemDefault()).toInstant());
    }
    public static Date localDateToDate(LocalDate l){
        return Date.from(l.atStartOfDay(ZoneId.systemDefault()).toInstant());
    }
}
